import { mapGetters } from 'vuex';
import { getBtnsId } from '@/libs/btnsPermission';
import { queryPermissionService } from '@/api/supplier/components';

export default {
  data () {
    return {
      exportLoading: false, // 导出按钮loading
      pagination: {
        current: 1,
        total: 0,
        size: 10
      },
      tableInfo: {
        list: [],
        selection: [],
        columns: [],
        loading: false
      },
    }
  },
  computed: {
    ...mapGetters('permissions/systemBtns', ['showBtn'])
  },
  methods: {
    // 获取表单内容
    getFormData (data) {
      this.formData = data;
    },
    // 表单查询
    handleQueryForm () {
      this.pagination.current = 1;
      this.getTableData();
    },
    // 页码切换
    handlePageChange (val) {
      this.pagination.current = val;
      this.getTableData();
    },
    // 每页条数切换
    handlePageSizeChange (val) {
      this.pagination.size = val;
      this.getTableData();
    },
    // 获取是否拥有编辑权限
    async queryDataPermissionAction (supplierId, btnText) {
      sessionStorage.setItem('buttonId', getBtnsId(btnText || '编辑'))
      const res = await queryPermissionService({ supplierId })
      return res?.result || false;
    },
    // 表格勾选操作
    selectionChange (rows) {
      this.tableInfo.selection = rows;
    },
  }
}
